package com.skymobi.cassandra.utils;

import java.io.UnsupportedEncodingException;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class StringUtils {
	private static final Logger logger = LoggerFactory
			.getLogger(StringUtils.class);
	private static final String ENCODE = "UTF-8";

	public static byte[] bytes(String str) {
		try {
			return str.getBytes(ENCODE);
		} catch (UnsupportedEncodingException e) {
			logger.error("UnsupportedEncodingException", e.getMessage());
			throw new RuntimeException(e);
		}
	}

	public static String string(byte[] bytes) {
		try {
			return new String(bytes, ENCODE);
		} catch (UnsupportedEncodingException e) {
			logger.error("UnsupportedEncodingException", e.getMessage());
			throw new RuntimeException(e);
		}
	}
}
